$(function () {
    //初始化编辑框
    initSNU({
        id:'courseOpen-details',
        type:1,
        toolsArr:null,
        height:360,
        gs:true,
        video:true
    });

    $("body").on('click','#save',function () {//保存
        saveCourseOpenInfo();
    }).on('click','#cancelLast',function () {//取消上一步
        window.location.href=baseloaction+"/admin/course/open/initUpdate?id="+$("input[name='id']").val();
    }).on('click','#cancel',function () {//取消
        window.history.go(-2);
    }).on('click',"#fristStep",function(){
        window.location.href=baseloaction+"/admin/course/open/initUpdate?id="+$("input[name='id']").val();
    });

    /**
     * 保存
     */
    function saveCourseOpenInfo() {
        $("#save").attr("disabled","disabled");
        var params = $("#courseOpen-depict-form").serializeJSON();
        params = JSON.stringify(params);
        $.ajax({
            url:baseloaction +'/admin/course/open/saveCourseOpenInfo',
            type:'post',
            dataType:'json',
            data:params,
            contentType:'application/json;charset=utf-8',
            success:function (result) {
                if(result.success==false){
                    $("#save").removeAttr('disabled');
                    icModale(0,result.message);
                }else{
                    window.location.href = baseloaction +'/admin/course/open/courseOpenList';
                }
            },
            error:function (error) {
                $("#save").removeAttr('disabled');
                icModale(0,'系统错误，免费直播描述信息保存失败');
            }
        });
    }
});